<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客正文</title>
    <link rel="stylesheet" href="css/conmmon.css">
    <link rel="stylesheet" href="css/blog_content.css">
</head>

<body>
    <!-- 导航栏 -->
    <div class="nav">
        <img src="img/doge.jpg" alt="">
        <span class="title">我的博客系统</span>
        <!-- 用来占据中间位置 -->
        <span class="spacer"></span>
        <!--<a href="blog_list.html">主页</a>-->
        <a href="blog_edit.html">写博客</a>
    </div>

    <!-- 版心 -->
    <div class="container">
        <!-- 左侧个人信息 -->
        <div class="container-left">
            <div class="card">
                <img id="myimage" class="avtar" alt="">  <!--修改 -->
                <h3 id = "name"></h3>     <!-- 修改 -->
                <a href="http:www.github.com">github 地址</a>
                <div class="counter">
                    <span>文章</span>
                </div>
                <div class="counter">
                    <span id = "acount"></span>
                </div>
            </div>
        </div>
        <!-- 右侧内容详情 -->
        <div class="container-right">
            <div class="blog-content">
                <!-- 博客标题 -->
                <h3 id = "title"></h3>
                <!-- 博客时间 -->
                <div id = "createtime" class="date">2021-06-02</div>
                <!-- 博客正文 -->
                <div id = "content">
                <p>
                    从今天起我要好好敲代码.
                    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aut recusandae omnis natus ut! Autem alias
                    ullam sit facilis ipsa dolore, molestiae neque aperiam in a facere dolor mollitia dolorum animi.
                    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aut recusandae omnis natus ut! Autem alias
                    ullam sit facilis ipsa dolore, molestiae neque aperiam in a facere dolor mollitia dolorum animi.
                    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aut recusandae omnis natus ut! Autem alias
                    ullam sit facilis ipsa dolore, molestiae neque aperiam in a facere dolor mollitia dolorum animi.
                </p>
                </div>
            </div>
        </div>
    </div>

</body>

<script src = "js/jquery.min.js"></script>
<script src = "js/mytools.js"></script>

<script>
    //alert("文章id是"+getParamKey("id"));
    //拿到当前页面的文章id
    var id = getParamKey("id");
    //判断id
    if(id != null && id > 0){
        //请求后端接口方法查询文章和用户信息
        jQuery.getJSON("/api/article/getdetail",{"id":id},function(data){
            if(data != null && data.status == 0 && data.data.id > 0){
                //此时文章已经查询到了
                //对文章和用户信息进行动态赋值
                var detail = data.data;
                jQuery("#name").html(detail.user.username); //设置用户名
                jQuery("#myimage").attr("src",detail.user.photo);  //设置用户头像
                //从url中取出文章发布的数量
                jQuery("#acount").text(getParamKey("acount"))
                jQuery("#title").html(detail.title);
                jQuery("#content").html(detail.content); //对于文章正文信息来说，只能设置为html，因为正文可能存在html标签
                //设置文章发布的时间
                var publishtime = detail.createtime;
                publishtime = publishtime.substring(0,publishtime.indexOf("T"));
                jQuery("#createtime").html(publishtime);
            }else{
                alert("查看文章详情失败！请重新操作")
            }
        })
    }
</script>

</html>